package com.start.shop.modules.service.impl;

import java.math.BigDecimal;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.start.shop.modules.repository.entity.Order;
import com.start.shop.modules.service.IOrderService;
import com.start.shop.modules.service.IPayNotify;

import lombok.extern.slf4j.Slf4j;

@Service
@Slf4j
public class PayNotify implements IPayNotify{

	@Autowired
	IOrderService orderService;
	
	//@Autowired
	//IAgentService agentService;
	
	
	/*
	 *  积分结果通知，积分处理为同步交易，支付失败的已经在feign过滤掉，所以这部分通知都是成功的交易
	 */
	
	@Override
	public void pointPayNotify(String orderNo, int userId, String payNo) {
		Order order= orderService.getOrderByOrderNo(userId, orderNo);
		
		//更新订单为已付款
		orderService.orderPaySuccess(userId, orderNo, payNo);
		
		int agentId = order.getAgentId();
		BigDecimal amount = order.getActualAmt().multiply(new BigDecimal(0.1));
		
		//购买成功入账
		//agentService.agentReward(agentId, amount);

	}

}
